<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="urf-8" />        
        <link href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/salusme/include/css/fal_style.css" rel="stylesheet" type="text/css" />
        <script src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] ?>/salusme/include/js/flash.js" type="text/javascript"></script>
        <script type="text/javascript">$(document).ready(function(){document.getElementById('maildata').value=$('#mainContent').html();});</script>
        <script type="text/javascript">function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');}</script>
        <script type="text/javascript" src="element.js?cb=googleTranslateElementInit"></script>
        <script type="text/javascript">

            function PrintElem(elem){Popup($(elem).html());}
            function Popup(data){
                var mywindow = window.open('', 'Print', 'height=700,width=600');                        
                mywindow.document.write(data);
                mywindow.document.close();
                mywindow.print();                
                return true;
            }
        </script>

        <link type="text/css" href="<?php echo 'http://' . $_SERVER['HTTP_HOST'] ?>/salusbaby/include/css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
        <script type="text/javascript" src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] ?>/salusbaby/include/js/jquery-1.7.2.js"></script>
        <script type="text/javascript" src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] ?>/salusbaby/include/js/jquery-ui-1.8.21.custom.min.js"></script>
        <script type="text/javascript">
            $(function(){

                // Accordion
                $("#accordion").accordion({ header: "h3",collapsible:true, autoHeight:false,navigation:true, active:false  });

                // Tabs
                $('#tabs').tabs();

                // Dialog
                $('#dialog').dialog({
                    autoOpen: false,
                    width: 600,
                    buttons: {
                        "Ok": function() {
                            $(this).dialog("close");
                        },
                        "Cancel": function() {
                            $(this).dialog("close");
                        }
                    }
                });

                // Dialog Link
                $('#dialog_link').click(function(){
                    $('#dialog').dialog('open');
                    return false;
                });

                // Datepicker
                $('#datepicker').datepicker({});

                // Slider
                $('#slider').slider({
                    range: true,
                    values: [17, 67]
                });

                // Progressbar
                $("#progressbar").progressbar({
                    value: 20
                });

                //hover states on the static widgets
                $('#dialog_link, ul#icons li').hover(
                function() { $(this).addClass('ui-state-hover'); },
                function() { $(this).removeClass('ui-state-hover'); }
            );

            });
        </script>
        <style>
            .bb th, .bb td{
                border-bottom:  1px #000000 dotted !important ;
            }
        </style>
        <style>
            .demoHeaders { margin-top: 2em; }
            #dialog_link,#dialog_link1, #dialog_link2  {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
            #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
            ul#icons {margin: 0; padding: 0;}
            ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
            ul#icons span.ui-icon {float: left; margin: 0 4px;}
            .bb th, .bb td{
                border-bottom:  1px #000000 dotted !important ;
                text-align: center;
            }
        </style>
        <script>
            $(function(){
                $('#dlg').click(function(){$('#dialog').dialog('open');return false;});
                $('#dlg1').click(function(){$('#dialog1').dialog('open');return false;});
                $("#dialog").dialog({autoOpen : false,modal : true,width : 'auto',height: 'auto',resizable : false,buttons: {"Don't Save": function() {$(this).dialog("close");}}});
                $("#dialog1").dialog({autoOpen : false,modal : true,width : 'auto',height: 'auto',resizable : false,buttons: {"Don't Save": function() {$(this).dialog("close");}}});
            });
        </script>
        <link rel="stylesheet" href="http://<?=$_SERVER['HTTP_HOST']?>/salusme/include/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
        <script src="http://<?=$_SERVER['HTTP_HOST']?>/salusme/include/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
        <div id="wrapper">
            <div id="header_small"></div>
            <div class="float_left profile_left margin_10">
                <div>
                    English
                    <div id="google_translate_element"></div>
                    <a href="index.php"><div class="main_menu">LOGOUT</div></a>
                </div><br/><br/><br/><br/><br/>                   
                <div class="clear"></div>
            </div>        
            <div class="salus_bank_reg float_left">
                <h2>Welcome, To Access Folders...!!!</h2>
                <div class="clear"></div>
                <hr>
                    <div id="mainContent">   
                        <?php
                        /*
                         * Authentication page of Folder Access.
                         */
                        include 'config.php';
                        $allextensions = array('jpg', 'gif', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG');
                        $uname = $_POST['user_name'];
                        $folder_name = $_POST['folder_name'];
                        $password = $_POST['password'];
                        $product_id = $_POST['pid'];
                        $baby = false;
                        $me = false;
                        /*
                         * getting user id.
                         */
                        $id1 = mysql_query("select id from fa_user where user_name = '$uname' ") or die(mysql_error());
                        if (mysql_num_rows($id1) != 0) {
                            while ($row0 = mysql_fetch_array($id1)) {
                                $uid = $row0['id'];
                            }
                        } else {
                            $error = 'Invalid Member';
                            header('Location:index.php?err=' . $error);
                            echo '<a href=index.php>Back</a><br>';
                            die('Invalid Member');
                        }

                        /*
                         * Checking for product id.
                         */

#for baby
                        $bid1 = mysql_query("select bid from baby_child_profile_detail where buyer_id= $uid") or die(mysql_error());
                        if (mysql_num_rows($bid1) != 0) {
                            while ($row = mysql_fetch_array($bid1)) {
                                $bid = $row['bid'];
                                $baby = true;
                            }
                        } else {
                            //echo '<br>not a part of baby<br>';
                        }

#for me
                        $me1 = mysql_query("select * from me_folders where uid = $uid ") or die(mysql_error());
                        if (mysql_num_rows($me1) != 0) {
                            $mid = $uid;
                            $me = true;
                        } else {
                            // echo '<br>Not member of me<br>';
                        }


                        if ($me == true) {
                            //echo '<br>me okokok.<br>';
                            /*
                             * checking for valid folder.
                             */
                            $content_path = 'http://' . $_SERVER['HTTP_HOST'] . '/salusme/storage/' . $mid . '/folders/' . $folder_name . '/';
                            $p1 = mysql_fetch_array(mysql_query("select pwd from me_folders where uid=$mid and folder='$folder_name' ")) or die(mysql_error());
                            $p = $p1['pwd'];
                            if ($p != $password) {
                                $error = 'Invalid Password';
                                header('Location:index.php');
                                echo '<a href=index.php>Back</a><br>';
                                die('Invalid Password');
                                
                            }
                            $mf1 = mysql_query("select * from me_folders where uid = $mid and folder= '$folder_name' ") or die(mysql_error());
                            if (mysql_num_rows($mf1) != 0) {
//        while ($row1 = mysql_fetch_array($mf1)) {
//            $me_folder_id = $row1['sr'];
//        }
                                /*
                                 * get contents of folder.
                                 */
                                $me_content = mysql_query("select * from me_upload_files where uid = $mid and mdir = '$folder_name' ") or die(mysql_error());
                                if (mysql_num_rows($me_content) != 0) {
                                    ?>
                                    <h3>Content Of SalusMe</h3>
                                    <div class="down_arrow"></div>                                
                                    <table width="600px;" class="bb">
                                        <tr>
                                            <th width="25px;" >Sr</th>
                                            <th width="575px;">File</th>                    
                                        </tr>

                                        <?php
                                        $i = 1;
                                        while ($row1 = mysql_fetch_array($me_content)) {
                                            ?>
                                            <tr>
                                                <td><?= $i ?></td>
                                                <td>
                                                    <?php
                                                    if ($row1['attr'] == '') {
                                                        $fn = $row1['file_name'];
                                                    } else {
                                                        $fn = $row1['attr'];
                                                    }
                                                    $ext = pathinfo($row1['file_name'], PATHINFO_EXTENSION);
                                                    if (in_array($ext, $allextensions)) {
                                                        echo '<a href="' . $content_path . $row1['file_name'] . '" rel="prettyPhoto" >' . $fn . '</a>';
                                                    } else {
                                                        echo '<a href="' . $content_path . $row1['file_name'] . '" >' . $fn . '</a>';
                                                    }
                                                    ?>
                                                </td>
                                            </tr>
                                            <?php
                                            $i++;
                                        }
                                        ?>
                                    </table>
                                    <?php
                                } else {
                                    echo 'no contents available';
                                }
                            } else {
                                $error = 'Invalid Folder Name.';
                                header('Location:index.php?err=' . $error);
                                echo '<a href=index.php>Back</a><br>';
                                echo 'Invalid Folder Name';
                            }
                        }
                        if ($baby == true) {
                            //echo '<br>baby okokok.<br>';
                            /*
                             * checking for valid folder.
                             */
                            $content_path = 'http://' . $_SERVER['HTTP_HOST'] . '/salusbaby/storage/' . $bid . '/folders/' . $folder_name . '/';
                            $p1 = mysql_fetch_array(mysql_query("select pwd from baby_folders where bid=$bid and folder='$folder_name' ")) or die(mysql_error());
                            $p = $p1['pwd'];
                            if ($p != $password) {
                                $error = 'Invalid Password';
                                header('Location:index.php?err=' . $error);
                                echo '<a href=index.php>Back</a><br>';
                                die('Invalid Password');
                            }
                            $mf1 = mysql_query("select * from baby_folders where bid = $bid and folder= '$folder_name' ") or die(mysql_error());
                            if (mysql_num_rows($mf1) != 0) {

                                /*
                                 * get contents of folder.
                                 */
                                $me_content = mysql_query("select * from baby_upload_files where bid = $bid and mdir = '$folder_name' ") or die(mysql_error());
                                if (mysql_num_rows($me_content) != 0) {
                                    ?>
                                    <h3>Content Of SalusBaby</h3>
                                    <div class="down_arrow"></div>                                
                                    <table width="600px;" class="bb">
                                        <tr>
                                            <th width="25px;" >Sr</th>
                                            <th width="575px;">File</th>                    
                                        </tr>

                                        <?php
                                        $i = 1;
                                        while ($row1 = mysql_fetch_array($me_content)) {
                                            ?>
                                            <tr>
                                                <td><?= $i ?></td>
                                                <td>
                                                    <?php
                                                    if ($row1['attr'] == '') {
                                                        $fn = $row1['file_name'];
                                                    } else {
                                                        $fn = $row1['attr'];
                                                    }
                                                    $ext = pathinfo($row1['file_name'], PATHINFO_EXTENSION);
                                                    if (in_array($ext, $allextensions)) {
                                                        echo '<a href="' . $content_path . $row1['file_name'] . '" rel="prettyPhoto" >' . $fn . '</a>';
                                                    } else {
                                                        echo '<a href="' . $content_path . $row1['file_name'] . '" >' . $fn . '</a>';
                                                    }
                                                    ?>
                                                </td>
                                            </tr>
                                            <?php
                                            $i++;
                                        }
                                        ?>
                                    </table>
                                    <?php
                                } else {
                                    echo 'no contents available';
                                }
                            } else {
                                $error = 'Invalid Folder Name';
                                header('Location:index.php?err=' . $error);
                                echo '<a href=index.php>Back</a><br>';
                                echo 'Invalid Folder Name';
                            }
                        }
                        ?>

                    </div>


            </div><!-- wrapper over    -->

            <div class="right_menu">                                
                <div>
                    <div class="news_title" >Calendar</div>        
                </div>
                <div>

                    <div id="datepicker" style="margin: 5px 0px 0px 1px; font-size: 8.7px; "></div>
                    <div id="dialog-a"></div>
                </div>

                <!--                    </div>-->
            </div>
            <div class="clear"></div>
            <script type="text/javascript" charset="utf-8">
                $(document).ready(function(){
                    $("area[rel^='prettyPhoto']").prettyPhoto();
    				
                    $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: false});
                    $(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'slow',slideshow:10000, hideflash: true});
    		
                    $("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
                        custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
                        changepicturecallback: function(){ initialize(); }
                    });

                    $("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
                        custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
                        changepicturecallback: function(){ _bsap.exec(); }
                    });
                });
            </script>
    </body>
</html>
